{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "ZIAkIlfmCe1B"
   },
   "source": [
    "# 神经元网络深度学习的起步程序 Hello World"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "fA93WUy1zzWf"
   },
   "source": [
    "Like every first app you should start with something super simple that shows the overall scaffolding for how your code works. \n",
    "\n",
    "In the case of creating neural networks, the sample I like to use is one where it learns the relationship between two numbers. So, for example, if you were writing code for a function like this, you already know the 'rules' -- \n",
    "\n",
    "第一个应用程序总是应该从超级简单的东西开始，这样可以看到代码如何产生和运作的整体框架。\n",
    "\n",
    "就创建神经网络而言，我喜欢使用的例子是一个能够学习两组数字之间函数关系的神经元。具体来说，如果你在写下面函数的代码，表明你已经知道了这个函数的\"规则\"，即x和y的映射关系。\n",
    "```\n",
    "float hw_function(float x){\n",
    "    float y = (2 * x) - 1;\n",
    "    return y;\n",
    "}\n",
    "```\n",
    "\n",
    "So how would you train a neural network to do the equivalent task? Using data! By feeding it with a set of Xs, and a set of Ys, it should be able to figure out the relationship between them. \n",
    "\n",
    "This is obviously a very different paradigm than what you might be used to, so let's step through it piece by piece.\n",
    "\n",
    "那么，如何训练一个神经网络来完成同等的任务呢? 用数据！用数据来训练神经网络。通过给它输入一组X，和一组Y，它应该能够找出它们之间的关系。\n",
    "\n",
    "这显然和你习惯的范式很不一样，所以让我们一步步来了解它。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "DzbtdRcZDO9B"
   },
   "source": [
    "## 导入tensorflow\n",
    "\n",
    "Let's start with our imports. Here we are importing TensorFlow and calling it tf for ease of use.\n",
    "\n",
    "We then import a library called numpy, which helps us to represent our data as lists easily and quickly.\n",
    "\n",
    "The framework for defining a neural network as a set of Sequential layers is called keras, so we import that too.\n",
    "让我们从导入TensorFlow开始。为了方便后续使用，我们把它叫做tf。\n",
    "\n",
    "然后我们导入一个名为numpy的库，它可以帮助我们方便快捷地将数据表示为列表。\n",
    "\n",
    "定义神经网络的框架叫做keras，它将神经元网络模型定义为一组Sequential层。Keras库也需要导入。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "X9uIpOS2zx7k"
   },
   "outputs": [],
   "source": [
    "import tensorflow as tf\n",
    "import numpy as np\n",
    "from tensorflow import keras"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "wwJGmDrQ0EoB"
   },
   "source": [
    "## 定义并编译神经元网络\n",
    "\n",
    "Next we will create the simplest possible neural network. It has 1 layer, and that layer has 1 neuron, and the input shape to it is just 1 value.\n",
    "接下来我们将创建一个最简单的神经网络。它只有1层，且这层只有1个神经元，它的输入只是1个数值。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "kQFAr_xo0M4T"
   },
   "outputs": [],
   "source": [
    "model = tf.keras.Sequential([keras.layers.Dense(units=1, input_shape=[1])])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "KhjZjZ-c0Ok9"
   },
   "source": [
    "Now we compile our Neural Network. When we do so, we have to specify 2 functions, a loss and an optimizer.\n",
    "\n",
    "If you've seen lots of math for machine learning, here's where it's usually used, but in this case it's nicely encapsulated in functions for you. But what happens here -- let's explain...\n",
    "\n",
    "We know that in our function, the relationship between the numbers is y=2x-1. \n",
    "\n",
    "When the computer is trying to 'learn' that, it makes a guess...maybe y=10x+10. The LOSS function measures the guessed answers against the known correct answers and measures how well or how badly it did.\n",
    "\n",
    "It then uses the OPTIMIZER function to make another guess. Based on how the loss function went, it will try to minimize the loss. At that point maybe it will come up with somehting like y=5x+5, which, while still pretty bad, is closer to the correct result (i.e. the loss is lower)\n",
    "\n",
    "It will repeat this for the number of EPOCHS which you will see shortly. But first, here's how we tell it to use 'MEAN SQUARED ERROR' for the loss and 'STOCHASTIC GRADIENT DESCENT' for the optimizer. You don't need to understand the math for these yet, but you can see that they work! :)\n",
    "\n",
    "Over time you will learn the different and appropriate loss and optimizer functions for different scenarios. \n",
    "\n",
    "在编译神经网络时，我们必须指定2个函数：一个损失函数和一个优化器。\n",
    "\n",
    "如果你读过很多有关机器学习的数学理论，这里通常是用到它们的地方。但Tensorflow将这些数学很好地封装在函数中供你使用。那么这个程序里到底发生了什么？我们来看一下：\n",
    "\n",
    "我们知道，在上面的函数中，两组数字之间的关系其实是y=2x-1。当计算机试图 \"学习 \"这个映射关系时，它猜测......也许y=10x+10。LOSS（损失）函数将猜测的答案与已知的正确答案进行比较，并衡量偏差程度。然后，计算机使用OPTIMIZER函数再做一次猜测，努力使损失最小化。这时，也许计算机会得出一些像y=5x+5这样的结果，虽然还是很糟糕，但更接近正确的结果（即损失更低）。训练的时候，将依据指定的EPOCHS次数，重复这样的猜测与优化过程。\n",
    "\n",
    "下面的程序中可以看到如何设置用 \"平均平方误差 \"来计算损失，并使用 \"同步梯度下降 \"来优化神经元网络。你并不需要理解背后的这些数学，但你可以看到它们的成效! :)\n",
    "\n",
    "随着经验的积累，你将了解如何选择相应的损失和优化函数，以适应不同的情况。\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "m8YQN1H41L-Y"
   },
   "outputs": [],
   "source": [
    "model.compile(optimizer='sgd', loss='mean_squared_error')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "5QyOUhFw1OUX"
   },
   "source": [
    "## Providing the Data 提供训练数据\n",
    "\n",
    "Next up we'll feed in some data. In this case we are taking 6 xs and 6ys. You can see that the relationship between these is that y=2x-1, so where x = -1, y=-3 etc. etc. \n",
    "\n",
    "A python library called 'Numpy' provides lots of array type data structures that are a defacto standard way of doing it. We declare that we want to use these by specifying the values asn an np.array[]\n",
    "\n",
    "接下来我们将提供一些数据。对于本案例，我们提供6个X和6个Y。可以看到它们之间的关系是y=2x-1，所以当X=-1，y=-3，以此类推。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "4Dxk4q-jzEy4"
   },
   "outputs": [],
   "source": [
    "xs = np.array([-1.0,  0.0, 1.0, 2.0, 3.0, 4.0], dtype=float)\n",
    "ys = np.array([-3.0, -1.0, 1.0, 3.0, 5.0, 7.0], dtype=float)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "n_YcWRElnM_b"
   },
   "source": [
    "# Training the Neural Network 训练神经元网络"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "c-Jk4dG91dvD"
   },
   "source": [
    "The process of training the neural network, where it 'learns' the relationship between the Xs and Ys is in the **model.fit**  call. This is where it will go through the loop we spoke about above, making a guess, measuring how good or bad it is (aka the loss), using the opimizer to make another guess etc. It will do it for the number of epochs you specify. When you run this code, you'll see the loss on the right hand side.\n",
    "\n",
    "在调用**model.fit**函数时，神经网络“学习”X和Y之间的关系。在这个过程中，它将一次又一次地完成上面所说的循环，即做一个猜测，衡量它有多好或多坏（又名损失），使用Opimizer进行再一次猜测，如此往复。训练将根据指定的遍数（epochs）执行此操作。当运行此代码时，将在输出结果中看到损失（loss）。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "collapsed": true,
    "id": "lpRrl7WK10Pq",
    "jupyter": {
     "outputs_hidden": true
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Epoch 1/500\n",
      "1/1 [==============================] - 0s 2ms/step - loss: 2.7835\n",
      "Epoch 2/500\n",
      "1/1 [==============================] - 0s 2ms/step - loss: 2.3434\n",
      "Epoch 3/500\n",
      "1/1 [==============================] - 0s 2ms/step - loss: 1.9939\n",
      "Epoch 4/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 1.7159\n",
      "Epoch 5/500\n",
      "1/1 [==============================] - 0s 2ms/step - loss: 1.4942\n",
      "Epoch 6/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 1.3168\n",
      "Epoch 7/500\n",
      "1/1 [==============================] - 0s 2ms/step - loss: 1.1743\n",
      "Epoch 8/500\n",
      "1/1 [==============================] - 0s 2ms/step - loss: 1.0594\n",
      "Epoch 9/500\n",
      "1/1 [==============================] - 0s 2ms/step - loss: 0.9662\n",
      "Epoch 10/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.8901\n",
      "Epoch 11/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.8276\n",
      "Epoch 12/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.7758\n",
      "Epoch 13/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.7325\n",
      "Epoch 14/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.6959\n",
      "Epoch 15/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.6647\n",
      "Epoch 16/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.6377\n",
      "Epoch 17/500\n",
      "1/1 [==============================] - 0s 2ms/step - loss: 0.6141\n",
      "Epoch 18/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.5932\n",
      "Epoch 19/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.5745\n",
      "Epoch 20/500\n",
      "1/1 [==============================] - 0s 934us/step - loss: 0.5576\n",
      "Epoch 21/500\n",
      "1/1 [==============================] - 0s 923us/step - loss: 0.5422\n",
      "Epoch 22/500\n",
      "1/1 [==============================] - 0s 885us/step - loss: 0.5279\n",
      "Epoch 23/500\n",
      "1/1 [==============================] - 0s 826us/step - loss: 0.5145\n",
      "Epoch 24/500\n",
      "1/1 [==============================] - 0s 920us/step - loss: 0.5020\n",
      "Epoch 25/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.4902\n",
      "Epoch 26/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.4789\n",
      "Epoch 27/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.4681\n",
      "Epoch 28/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.4577\n",
      "Epoch 29/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.4477\n",
      "Epoch 30/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.4381\n",
      "Epoch 31/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.4287\n",
      "Epoch 32/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.4196\n",
      "Epoch 33/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.4108\n",
      "Epoch 34/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.4022\n",
      "Epoch 35/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.3938\n",
      "Epoch 36/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.3856\n",
      "Epoch 37/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.3775\n",
      "Epoch 38/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.3697\n",
      "Epoch 39/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.3621\n",
      "Epoch 40/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.3546\n",
      "Epoch 41/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.3473\n",
      "Epoch 42/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.3401\n",
      "Epoch 43/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.3331\n",
      "Epoch 44/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.3263\n",
      "Epoch 45/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.3195\n",
      "Epoch 46/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.3130\n",
      "Epoch 47/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.3065\n",
      "Epoch 48/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.3002\n",
      "Epoch 49/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.2941\n",
      "Epoch 50/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.2880\n",
      "Epoch 51/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.2821\n",
      "Epoch 52/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.2763\n",
      "Epoch 53/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.2706\n",
      "Epoch 54/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.2651\n",
      "Epoch 55/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.2596\n",
      "Epoch 56/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.2543\n",
      "Epoch 57/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.2491\n",
      "Epoch 58/500\n",
      "1/1 [==============================] - 0s 933us/step - loss: 0.2439\n",
      "Epoch 59/500\n",
      "1/1 [==============================] - 0s 986us/step - loss: 0.2389\n",
      "Epoch 60/500\n",
      "1/1 [==============================] - 0s 934us/step - loss: 0.2340\n",
      "Epoch 61/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.2292\n",
      "Epoch 62/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.2245\n",
      "Epoch 63/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.2199\n",
      "Epoch 64/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.2154\n",
      "Epoch 65/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.2110\n",
      "Epoch 66/500\n",
      "1/1 [==============================] - 0s 967us/step - loss: 0.2066\n",
      "Epoch 67/500\n",
      "1/1 [==============================] - 0s 993us/step - loss: 0.2024\n",
      "Epoch 68/500\n",
      "1/1 [==============================] - 0s 862us/step - loss: 0.1982\n",
      "Epoch 69/500\n",
      "1/1 [==============================] - 0s 892us/step - loss: 0.1941\n",
      "Epoch 70/500\n",
      "1/1 [==============================] - 0s 976us/step - loss: 0.1902\n",
      "Epoch 71/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.1863\n",
      "Epoch 72/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.1824\n",
      "Epoch 73/500\n",
      "1/1 [==============================] - 0s 817us/step - loss: 0.1787\n",
      "Epoch 74/500\n",
      "1/1 [==============================] - 0s 981us/step - loss: 0.1750\n",
      "Epoch 75/500\n",
      "1/1 [==============================] - 0s 960us/step - loss: 0.1714\n",
      "Epoch 76/500\n",
      "1/1 [==============================] - 0s 835us/step - loss: 0.1679\n",
      "Epoch 77/500\n",
      "1/1 [==============================] - 0s 956us/step - loss: 0.1644\n",
      "Epoch 78/500\n",
      "1/1 [==============================] - 0s 938us/step - loss: 0.1611\n",
      "Epoch 79/500\n",
      "1/1 [==============================] - 0s 867us/step - loss: 0.1578\n",
      "Epoch 80/500\n",
      "1/1 [==============================] - 0s 875us/step - loss: 0.1545\n",
      "Epoch 81/500\n",
      "1/1 [==============================] - 0s 959us/step - loss: 0.1513\n",
      "Epoch 82/500\n",
      "1/1 [==============================] - 0s 2ms/step - loss: 0.1482\n",
      "Epoch 83/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.1452\n",
      "Epoch 84/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.1422\n",
      "Epoch 85/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.1393\n",
      "Epoch 86/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.1364\n",
      "Epoch 87/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.1336\n",
      "Epoch 88/500\n",
      "1/1 [==============================] - 0s 765us/step - loss: 0.1309\n",
      "Epoch 89/500\n",
      "1/1 [==============================] - 0s 928us/step - loss: 0.1282\n",
      "Epoch 90/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.1256\n",
      "Epoch 91/500\n",
      "1/1 [==============================] - 0s 838us/step - loss: 0.1230\n",
      "Epoch 92/500\n",
      "1/1 [==============================] - 0s 906us/step - loss: 0.1205\n",
      "Epoch 93/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.1180\n",
      "Epoch 94/500\n",
      "1/1 [==============================] - 0s 741us/step - loss: 0.1156\n",
      "Epoch 95/500\n",
      "1/1 [==============================] - 0s 908us/step - loss: 0.1132\n",
      "Epoch 96/500\n",
      "1/1 [==============================] - 0s 992us/step - loss: 0.1109\n",
      "Epoch 97/500\n",
      "1/1 [==============================] - 0s 857us/step - loss: 0.1086\n",
      "Epoch 98/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.1064\n",
      "Epoch 99/500\n",
      "1/1 [==============================] - 0s 990us/step - loss: 0.1042\n",
      "Epoch 100/500\n",
      "1/1 [==============================] - 0s 971us/step - loss: 0.1020\n",
      "Epoch 101/500\n",
      "1/1 [==============================] - 0s 973us/step - loss: 0.0999\n",
      "Epoch 102/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0979\n",
      "Epoch 103/500\n",
      "1/1 [==============================] - 0s 4ms/step - loss: 0.0959\n",
      "Epoch 104/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0939\n",
      "Epoch 105/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0920\n",
      "Epoch 106/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0901\n",
      "Epoch 107/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0882\n",
      "Epoch 108/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0864\n",
      "Epoch 109/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0846\n",
      "Epoch 110/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0829\n",
      "Epoch 111/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0812\n",
      "Epoch 112/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0795\n",
      "Epoch 113/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0779\n",
      "Epoch 114/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0763\n",
      "Epoch 115/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0747\n",
      "Epoch 116/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0732\n",
      "Epoch 117/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0717\n",
      "Epoch 118/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0702\n",
      "Epoch 119/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0688\n",
      "Epoch 120/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0674\n",
      "Epoch 121/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0660\n",
      "Epoch 122/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0646\n",
      "Epoch 123/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0633\n",
      "Epoch 124/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0620\n",
      "Epoch 125/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0607\n",
      "Epoch 126/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0595\n",
      "Epoch 127/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0583\n",
      "Epoch 128/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0571\n",
      "Epoch 129/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0559\n",
      "Epoch 130/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0547\n",
      "Epoch 131/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0536\n",
      "Epoch 132/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0525\n",
      "Epoch 133/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0514\n",
      "Epoch 134/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0504\n",
      "Epoch 135/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0493\n",
      "Epoch 136/500\n",
      "1/1 [==============================] - 0s 940us/step - loss: 0.0483\n",
      "Epoch 137/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0473\n",
      "Epoch 138/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0464\n",
      "Epoch 139/500\n",
      "1/1 [==============================] - 0s 832us/step - loss: 0.0454\n",
      "Epoch 140/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0445\n",
      "Epoch 141/500\n",
      "1/1 [==============================] - 0s 921us/step - loss: 0.0436\n",
      "Epoch 142/500\n",
      "1/1 [==============================] - 0s 915us/step - loss: 0.0427\n",
      "Epoch 143/500\n",
      "1/1 [==============================] - 0s 952us/step - loss: 0.0418\n",
      "Epoch 144/500\n",
      "1/1 [==============================] - 0s 877us/step - loss: 0.0409\n",
      "Epoch 145/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0401\n",
      "Epoch 146/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0393\n",
      "Epoch 147/500\n",
      "1/1 [==============================] - 0s 976us/step - loss: 0.0385\n",
      "Epoch 148/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0377\n",
      "Epoch 149/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0369\n",
      "Epoch 150/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0361\n",
      "Epoch 151/500\n",
      "1/1 [==============================] - 0s 931us/step - loss: 0.0354\n",
      "Epoch 152/500\n",
      "1/1 [==============================] - 0s 913us/step - loss: 0.0347\n",
      "Epoch 153/500\n",
      "1/1 [==============================] - 0s 976us/step - loss: 0.0340\n",
      "Epoch 154/500\n",
      "1/1 [==============================] - 0s 997us/step - loss: 0.0333\n",
      "Epoch 155/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0326\n",
      "Epoch 156/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0319\n",
      "Epoch 157/500\n",
      "1/1 [==============================] - 0s 971us/step - loss: 0.0313\n",
      "Epoch 158/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0306\n",
      "Epoch 159/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0300\n",
      "Epoch 160/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0294\n",
      "Epoch 161/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0288\n",
      "Epoch 162/500\n",
      "1/1 [==============================] - 0s 962us/step - loss: 0.0282\n",
      "Epoch 163/500\n",
      "1/1 [==============================] - 0s 896us/step - loss: 0.0276\n",
      "Epoch 164/500\n",
      "1/1 [==============================] - 0s 895us/step - loss: 0.0270\n",
      "Epoch 165/500\n",
      "1/1 [==============================] - 0s 31ms/step - loss: 0.0265\n",
      "Epoch 166/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0259\n",
      "Epoch 167/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0254\n",
      "Epoch 168/500\n",
      "1/1 [==============================] - 0s 984us/step - loss: 0.0249\n",
      "Epoch 169/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0244\n",
      "Epoch 170/500\n",
      "1/1 [==============================] - 0s 956us/step - loss: 0.0239\n",
      "Epoch 171/500\n",
      "1/1 [==============================] - 0s 954us/step - loss: 0.0234\n",
      "Epoch 172/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0229\n",
      "Epoch 173/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0224\n",
      "Epoch 174/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0220\n",
      "Epoch 175/500\n",
      "1/1 [==============================] - 0s 900us/step - loss: 0.0215\n",
      "Epoch 176/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0211\n",
      "Epoch 177/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0206\n",
      "Epoch 178/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0202\n",
      "Epoch 179/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0198\n",
      "Epoch 180/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0194\n",
      "Epoch 181/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0190\n",
      "Epoch 182/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0186\n",
      "Epoch 183/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0182\n",
      "Epoch 184/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0178\n",
      "Epoch 185/500\n",
      "1/1 [==============================] - 0s 948us/step - loss: 0.0175\n",
      "Epoch 186/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0171\n",
      "Epoch 187/500\n",
      "1/1 [==============================] - 0s 896us/step - loss: 0.0168\n",
      "Epoch 188/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0164\n",
      "Epoch 189/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0161\n",
      "Epoch 190/500\n",
      "1/1 [==============================] - 0s 1000us/step - loss: 0.0158\n",
      "Epoch 191/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0154\n",
      "Epoch 192/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0151\n",
      "Epoch 193/500\n",
      "1/1 [==============================] - 0s 939us/step - loss: 0.0148\n",
      "Epoch 194/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0145\n",
      "Epoch 195/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0142\n",
      "Epoch 196/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0139\n",
      "Epoch 197/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0136\n",
      "Epoch 198/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0133\n",
      "Epoch 199/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0131\n",
      "Epoch 200/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0128\n",
      "Epoch 201/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0125\n",
      "Epoch 202/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0123\n",
      "Epoch 203/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0120\n",
      "Epoch 204/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0118\n",
      "Epoch 205/500\n",
      "1/1 [==============================] - 0s 973us/step - loss: 0.0115\n",
      "Epoch 206/500\n",
      "1/1 [==============================] - 0s 978us/step - loss: 0.0113\n",
      "Epoch 207/500\n",
      "1/1 [==============================] - 0s 943us/step - loss: 0.0111\n",
      "Epoch 208/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0108\n",
      "Epoch 209/500\n",
      "1/1 [==============================] - 0s 964us/step - loss: 0.0106\n",
      "Epoch 210/500\n",
      "1/1 [==============================] - 0s 884us/step - loss: 0.0104\n",
      "Epoch 211/500\n",
      "1/1 [==============================] - 0s 841us/step - loss: 0.0102\n",
      "Epoch 212/500\n",
      "1/1 [==============================] - 0s 985us/step - loss: 0.0100\n",
      "Epoch 213/500\n",
      "1/1 [==============================] - 0s 858us/step - loss: 0.0098\n",
      "Epoch 214/500\n",
      "1/1 [==============================] - 0s 859us/step - loss: 0.0096\n",
      "Epoch 215/500\n",
      "1/1 [==============================] - 0s 942us/step - loss: 0.0094\n",
      "Epoch 216/500\n",
      "1/1 [==============================] - 0s 867us/step - loss: 0.0092\n",
      "Epoch 217/500\n",
      "1/1 [==============================] - 0s 912us/step - loss: 0.0090\n",
      "Epoch 218/500\n",
      "1/1 [==============================] - 0s 936us/step - loss: 0.0088\n",
      "Epoch 219/500\n",
      "1/1 [==============================] - 0s 944us/step - loss: 0.0086\n",
      "Epoch 220/500\n",
      "1/1 [==============================] - 0s 942us/step - loss: 0.0085\n",
      "Epoch 221/500\n",
      "1/1 [==============================] - 0s 911us/step - loss: 0.0083\n",
      "Epoch 222/500\n",
      "1/1 [==============================] - 0s 929us/step - loss: 0.0081\n",
      "Epoch 223/500\n",
      "1/1 [==============================] - 0s 889us/step - loss: 0.0079\n",
      "Epoch 224/500\n",
      "1/1 [==============================] - 0s 917us/step - loss: 0.0078\n",
      "Epoch 225/500\n",
      "1/1 [==============================] - 0s 821us/step - loss: 0.0076\n",
      "Epoch 226/500\n",
      "1/1 [==============================] - 0s 889us/step - loss: 0.0075\n",
      "Epoch 227/500\n",
      "1/1 [==============================] - 0s 939us/step - loss: 0.0073\n",
      "Epoch 228/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0072\n",
      "Epoch 229/500\n",
      "1/1 [==============================] - 0s 920us/step - loss: 0.0070\n",
      "Epoch 230/500\n",
      "1/1 [==============================] - 0s 900us/step - loss: 0.0069\n",
      "Epoch 231/500\n",
      "1/1 [==============================] - 0s 884us/step - loss: 0.0067\n",
      "Epoch 232/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0066\n",
      "Epoch 233/500\n",
      "1/1 [==============================] - 0s 797us/step - loss: 0.0065\n",
      "Epoch 234/500\n",
      "1/1 [==============================] - 0s 823us/step - loss: 0.0063\n",
      "Epoch 235/500\n",
      "1/1 [==============================] - 0s 939us/step - loss: 0.0062\n",
      "Epoch 236/500\n",
      "1/1 [==============================] - 0s 782us/step - loss: 0.0061\n",
      "Epoch 237/500\n",
      "1/1 [==============================] - 0s 928us/step - loss: 0.0059\n",
      "Epoch 238/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0058\n",
      "Epoch 239/500\n",
      "1/1 [==============================] - 0s 803us/step - loss: 0.0057\n",
      "Epoch 240/500\n",
      "1/1 [==============================] - 0s 952us/step - loss: 0.0056\n",
      "Epoch 241/500\n",
      "1/1 [==============================] - 0s 2ms/step - loss: 0.0055\n",
      "Epoch 242/500\n",
      "1/1 [==============================] - 0s 856us/step - loss: 0.0054\n",
      "Epoch 243/500\n",
      "1/1 [==============================] - 0s 834us/step - loss: 0.0052\n",
      "Epoch 244/500\n",
      "1/1 [==============================] - 0s 780us/step - loss: 0.0051\n",
      "Epoch 245/500\n",
      "1/1 [==============================] - 0s 950us/step - loss: 0.0050\n",
      "Epoch 246/500\n",
      "1/1 [==============================] - 0s 934us/step - loss: 0.0049\n",
      "Epoch 247/500\n",
      "1/1 [==============================] - 0s 766us/step - loss: 0.0048\n",
      "Epoch 248/500\n",
      "1/1 [==============================] - 0s 962us/step - loss: 0.0047\n",
      "Epoch 249/500\n",
      "1/1 [==============================] - 0s 730us/step - loss: 0.0046\n",
      "Epoch 250/500\n",
      "1/1 [==============================] - 0s 874us/step - loss: 0.0045\n",
      "Epoch 251/500\n",
      "1/1 [==============================] - 0s 841us/step - loss: 0.0044\n",
      "Epoch 252/500\n",
      "1/1 [==============================] - 0s 785us/step - loss: 0.0044\n",
      "Epoch 253/500\n",
      "1/1 [==============================] - 0s 899us/step - loss: 0.0043\n",
      "Epoch 254/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0042\n",
      "Epoch 255/500\n",
      "1/1 [==============================] - 0s 916us/step - loss: 0.0041\n",
      "Epoch 256/500\n",
      "1/1 [==============================] - 0s 810us/step - loss: 0.0040\n",
      "Epoch 257/500\n",
      "1/1 [==============================] - 0s 890us/step - loss: 0.0039\n",
      "Epoch 258/500\n",
      "1/1 [==============================] - 0s 852us/step - loss: 0.0038\n",
      "Epoch 259/500\n",
      "1/1 [==============================] - 0s 920us/step - loss: 0.0038\n",
      "Epoch 260/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0037\n",
      "Epoch 261/500\n",
      "1/1 [==============================] - 0s 829us/step - loss: 0.0036\n",
      "Epoch 262/500\n",
      "1/1 [==============================] - 0s 881us/step - loss: 0.0035\n",
      "Epoch 263/500\n",
      "1/1 [==============================] - 0s 875us/step - loss: 0.0035\n",
      "Epoch 264/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0034\n",
      "Epoch 265/500\n",
      "1/1 [==============================] - 0s 941us/step - loss: 0.0033\n",
      "Epoch 266/500\n",
      "1/1 [==============================] - 0s 848us/step - loss: 0.0033\n",
      "Epoch 267/500\n",
      "1/1 [==============================] - 0s 690us/step - loss: 0.0032\n",
      "Epoch 268/500\n",
      "1/1 [==============================] - 0s 806us/step - loss: 0.0031\n",
      "Epoch 269/500\n",
      "1/1 [==============================] - 0s 923us/step - loss: 0.0031\n",
      "Epoch 270/500\n",
      "1/1 [==============================] - 0s 939us/step - loss: 0.0030\n",
      "Epoch 271/500\n",
      "1/1 [==============================] - 0s 782us/step - loss: 0.0029\n",
      "Epoch 272/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0029\n",
      "Epoch 273/500\n",
      "1/1 [==============================] - 0s 2ms/step - loss: 0.0028\n",
      "Epoch 274/500\n",
      "1/1 [==============================] - 0s 749us/step - loss: 0.0028\n",
      "Epoch 275/500\n",
      "1/1 [==============================] - 0s 2ms/step - loss: 0.0027\n",
      "Epoch 276/500\n",
      "1/1 [==============================] - 0s 756us/step - loss: 0.0026\n",
      "Epoch 277/500\n",
      "1/1 [==============================] - 0s 728us/step - loss: 0.0026\n",
      "Epoch 278/500\n",
      "1/1 [==============================] - 0s 670us/step - loss: 0.0025\n",
      "Epoch 279/500\n",
      "1/1 [==============================] - 0s 921us/step - loss: 0.0025\n",
      "Epoch 280/500\n",
      "1/1 [==============================] - 0s 880us/step - loss: 0.0024\n",
      "Epoch 281/500\n",
      "1/1 [==============================] - 0s 741us/step - loss: 0.0024\n",
      "Epoch 282/500\n",
      "1/1 [==============================] - 0s 706us/step - loss: 0.0023\n",
      "Epoch 283/500\n",
      "1/1 [==============================] - 0s 716us/step - loss: 0.0023\n",
      "Epoch 284/500\n",
      "1/1 [==============================] - 0s 790us/step - loss: 0.0022\n",
      "Epoch 285/500\n",
      "1/1 [==============================] - 0s 862us/step - loss: 0.0022\n",
      "Epoch 286/500\n",
      "1/1 [==============================] - 0s 683us/step - loss: 0.0021\n",
      "Epoch 287/500\n",
      "1/1 [==============================] - 0s 702us/step - loss: 0.0021\n",
      "Epoch 288/500\n",
      "1/1 [==============================] - 0s 729us/step - loss: 0.0021\n",
      "Epoch 289/500\n",
      "1/1 [==============================] - 0s 710us/step - loss: 0.0020\n",
      "Epoch 290/500\n",
      "1/1 [==============================] - 0s 2ms/step - loss: 0.0020\n",
      "Epoch 291/500\n",
      "1/1 [==============================] - 0s 818us/step - loss: 0.0019\n",
      "Epoch 292/500\n",
      "1/1 [==============================] - 0s 777us/step - loss: 0.0019\n",
      "Epoch 293/500\n",
      "1/1 [==============================] - 0s 933us/step - loss: 0.0019\n",
      "Epoch 294/500\n",
      "1/1 [==============================] - 0s 891us/step - loss: 0.0018\n",
      "Epoch 295/500\n",
      "1/1 [==============================] - 0s 967us/step - loss: 0.0018\n",
      "Epoch 296/500\n",
      "1/1 [==============================] - 0s 971us/step - loss: 0.0017\n",
      "Epoch 297/500\n",
      "1/1 [==============================] - 0s 900us/step - loss: 0.0017\n",
      "Epoch 298/500\n",
      "1/1 [==============================] - 0s 774us/step - loss: 0.0017\n",
      "Epoch 299/500\n",
      "1/1 [==============================] - 0s 822us/step - loss: 0.0016\n",
      "Epoch 300/500\n",
      "1/1 [==============================] - 0s 842us/step - loss: 0.0016\n",
      "Epoch 301/500\n",
      "1/1 [==============================] - 0s 777us/step - loss: 0.0016\n",
      "Epoch 302/500\n",
      "1/1 [==============================] - 0s 882us/step - loss: 0.0015\n",
      "Epoch 303/500\n",
      "1/1 [==============================] - 0s 872us/step - loss: 0.0015\n",
      "Epoch 304/500\n",
      "1/1 [==============================] - 0s 829us/step - loss: 0.0015\n",
      "Epoch 305/500\n",
      "1/1 [==============================] - 0s 839us/step - loss: 0.0014\n",
      "Epoch 306/500\n",
      "1/1 [==============================] - 0s 2ms/step - loss: 0.0014\n",
      "Epoch 307/500\n",
      "1/1 [==============================] - 0s 817us/step - loss: 0.0014\n",
      "Epoch 308/500\n",
      "1/1 [==============================] - 0s 949us/step - loss: 0.0014\n",
      "Epoch 309/500\n",
      "1/1 [==============================] - 0s 897us/step - loss: 0.0013\n",
      "Epoch 310/500\n",
      "1/1 [==============================] - 0s 958us/step - loss: 0.0013\n",
      "Epoch 311/500\n",
      "1/1 [==============================] - 0s 962us/step - loss: 0.0013\n",
      "Epoch 312/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 0.0013\n",
      "Epoch 313/500\n",
      "1/1 [==============================] - 0s 997us/step - loss: 0.0012\n",
      "Epoch 314/500\n",
      "1/1 [==============================] - 0s 955us/step - loss: 0.0012\n",
      "Epoch 315/500\n",
      "1/1 [==============================] - 0s 858us/step - loss: 0.0012\n",
      "Epoch 316/500\n",
      "1/1 [==============================] - 0s 795us/step - loss: 0.0012\n",
      "Epoch 317/500\n",
      "1/1 [==============================] - 0s 863us/step - loss: 0.0011\n",
      "Epoch 318/500\n",
      "1/1 [==============================] - 0s 858us/step - loss: 0.0011\n",
      "Epoch 319/500\n",
      "1/1 [==============================] - 0s 980us/step - loss: 0.0011\n",
      "Epoch 320/500\n",
      "1/1 [==============================] - 0s 792us/step - loss: 0.0011\n",
      "Epoch 321/500\n",
      "1/1 [==============================] - 0s 925us/step - loss: 0.0010\n",
      "Epoch 322/500\n",
      "1/1 [==============================] - 0s 955us/step - loss: 0.0010\n",
      "Epoch 323/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 9.9699e-04\n",
      "Epoch 324/500\n",
      "1/1 [==============================] - 0s 997us/step - loss: 9.7651e-04\n",
      "Epoch 325/500\n",
      "1/1 [==============================] - 0s 815us/step - loss: 9.5645e-04\n",
      "Epoch 326/500\n",
      "1/1 [==============================] - 0s 819us/step - loss: 9.3681e-04\n",
      "Epoch 327/500\n",
      "1/1 [==============================] - 0s 829us/step - loss: 9.1756e-04\n",
      "Epoch 328/500\n",
      "1/1 [==============================] - 0s 809us/step - loss: 8.9872e-04\n",
      "Epoch 329/500\n",
      "1/1 [==============================] - 0s 900us/step - loss: 8.8026e-04\n",
      "Epoch 330/500\n",
      "1/1 [==============================] - 0s 885us/step - loss: 8.6218e-04\n",
      "Epoch 331/500\n",
      "1/1 [==============================] - 0s 864us/step - loss: 8.4446e-04\n",
      "Epoch 332/500\n",
      "1/1 [==============================] - 0s 784us/step - loss: 8.2712e-04\n",
      "Epoch 333/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 8.1013e-04\n",
      "Epoch 334/500\n",
      "1/1 [==============================] - 0s 685us/step - loss: 7.9349e-04\n",
      "Epoch 335/500\n",
      "1/1 [==============================] - 0s 905us/step - loss: 7.7719e-04\n",
      "Epoch 336/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 7.6123e-04\n",
      "Epoch 337/500\n",
      "1/1 [==============================] - 0s 726us/step - loss: 7.4559e-04\n",
      "Epoch 338/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 7.3028e-04\n",
      "Epoch 339/500\n",
      "1/1 [==============================] - 0s 837us/step - loss: 7.1528e-04\n",
      "Epoch 340/500\n",
      "1/1 [==============================] - 0s 756us/step - loss: 7.0058e-04\n",
      "Epoch 341/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 6.8620e-04\n",
      "Epoch 342/500\n",
      "1/1 [==============================] - 0s 731us/step - loss: 6.7210e-04\n",
      "Epoch 343/500\n",
      "1/1 [==============================] - 0s 874us/step - loss: 6.5829e-04\n",
      "Epoch 344/500\n",
      "1/1 [==============================] - 0s 865us/step - loss: 6.4477e-04\n",
      "Epoch 345/500\n",
      "1/1 [==============================] - 0s 869us/step - loss: 6.3153e-04\n",
      "Epoch 346/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 6.1856e-04\n",
      "Epoch 347/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 6.0585e-04\n",
      "Epoch 348/500\n",
      "1/1 [==============================] - 0s 750us/step - loss: 5.9341e-04\n",
      "Epoch 349/500\n",
      "1/1 [==============================] - 0s 836us/step - loss: 5.8122e-04\n",
      "Epoch 350/500\n",
      "1/1 [==============================] - 0s 762us/step - loss: 5.6928e-04\n",
      "Epoch 351/500\n",
      "1/1 [==============================] - 0s 698us/step - loss: 5.5758e-04\n",
      "Epoch 352/500\n",
      "1/1 [==============================] - 0s 896us/step - loss: 5.4613e-04\n",
      "Epoch 353/500\n",
      "1/1 [==============================] - 0s 894us/step - loss: 5.3491e-04\n",
      "Epoch 354/500\n",
      "1/1 [==============================] - 0s 802us/step - loss: 5.2393e-04\n",
      "Epoch 355/500\n",
      "1/1 [==============================] - 0s 702us/step - loss: 5.1317e-04\n",
      "Epoch 356/500\n",
      "1/1 [==============================] - 0s 904us/step - loss: 5.0263e-04\n",
      "Epoch 357/500\n",
      "1/1 [==============================] - 0s 720us/step - loss: 4.9230e-04\n",
      "Epoch 358/500\n",
      "1/1 [==============================] - 0s 840us/step - loss: 4.8219e-04\n",
      "Epoch 359/500\n",
      "1/1 [==============================] - 0s 886us/step - loss: 4.7228e-04\n",
      "Epoch 360/500\n",
      "1/1 [==============================] - 0s 850us/step - loss: 4.6258e-04\n",
      "Epoch 361/500\n",
      "1/1 [==============================] - 0s 915us/step - loss: 4.5308e-04\n",
      "Epoch 362/500\n",
      "1/1 [==============================] - 0s 845us/step - loss: 4.4377e-04\n",
      "Epoch 363/500\n",
      "1/1 [==============================] - 0s 2ms/step - loss: 4.3466e-04\n",
      "Epoch 364/500\n",
      "1/1 [==============================] - 0s 896us/step - loss: 4.2573e-04\n",
      "Epoch 365/500\n",
      "1/1 [==============================] - 0s 837us/step - loss: 4.1698e-04\n",
      "Epoch 366/500\n",
      "1/1 [==============================] - 0s 784us/step - loss: 4.0842e-04\n",
      "Epoch 367/500\n",
      "1/1 [==============================] - 0s 891us/step - loss: 4.0003e-04\n",
      "Epoch 368/500\n",
      "1/1 [==============================] - 0s 866us/step - loss: 3.9181e-04\n",
      "Epoch 369/500\n",
      "1/1 [==============================] - 0s 2ms/step - loss: 3.8377e-04\n",
      "Epoch 370/500\n",
      "1/1 [==============================] - 0s 870us/step - loss: 3.7588e-04\n",
      "Epoch 371/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 3.6816e-04\n",
      "Epoch 372/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 3.6060e-04\n",
      "Epoch 373/500\n",
      "1/1 [==============================] - 0s 4ms/step - loss: 3.5319e-04\n",
      "Epoch 374/500\n",
      "1/1 [==============================] - 0s 825us/step - loss: 3.4594e-04\n",
      "Epoch 375/500\n",
      "1/1 [==============================] - 0s 755us/step - loss: 3.3883e-04\n",
      "Epoch 376/500\n",
      "1/1 [==============================] - 0s 861us/step - loss: 3.3188e-04\n",
      "Epoch 377/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 3.2506e-04\n",
      "Epoch 378/500\n",
      "1/1 [==============================] - 0s 737us/step - loss: 3.1838e-04\n",
      "Epoch 379/500\n",
      "1/1 [==============================] - 0s 924us/step - loss: 3.1184e-04\n",
      "Epoch 380/500\n",
      "1/1 [==============================] - 0s 764us/step - loss: 3.0544e-04\n",
      "Epoch 381/500\n",
      "1/1 [==============================] - 0s 865us/step - loss: 2.9916e-04\n",
      "Epoch 382/500\n",
      "1/1 [==============================] - 0s 982us/step - loss: 2.9302e-04\n",
      "Epoch 383/500\n",
      "1/1 [==============================] - 0s 855us/step - loss: 2.8700e-04\n",
      "Epoch 384/500\n",
      "1/1 [==============================] - 0s 886us/step - loss: 2.8110e-04\n",
      "Epoch 385/500\n",
      "1/1 [==============================] - 0s 752us/step - loss: 2.7533e-04\n",
      "Epoch 386/500\n",
      "1/1 [==============================] - 0s 746us/step - loss: 2.6967e-04\n",
      "Epoch 387/500\n",
      "1/1 [==============================] - 0s 932us/step - loss: 2.6413e-04\n",
      "Epoch 388/500\n",
      "1/1 [==============================] - 0s 876us/step - loss: 2.5871e-04\n",
      "Epoch 389/500\n",
      "1/1 [==============================] - 0s 965us/step - loss: 2.5339e-04\n",
      "Epoch 390/500\n",
      "1/1 [==============================] - 0s 938us/step - loss: 2.4819e-04\n",
      "Epoch 391/500\n",
      "1/1 [==============================] - 0s 892us/step - loss: 2.4309e-04\n",
      "Epoch 392/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 2.3810e-04\n",
      "Epoch 393/500\n",
      "1/1 [==============================] - 0s 736us/step - loss: 2.3321e-04\n",
      "Epoch 394/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 2.2842e-04\n",
      "Epoch 395/500\n",
      "1/1 [==============================] - 0s 931us/step - loss: 2.2373e-04\n",
      "Epoch 396/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 2.1913e-04\n",
      "Epoch 397/500\n",
      "1/1 [==============================] - 0s 792us/step - loss: 2.1463e-04\n",
      "Epoch 398/500\n",
      "1/1 [==============================] - 0s 825us/step - loss: 2.1022e-04\n",
      "Epoch 399/500\n",
      "1/1 [==============================] - 0s 958us/step - loss: 2.0590e-04\n",
      "Epoch 400/500\n",
      "1/1 [==============================] - 0s 811us/step - loss: 2.0167e-04\n",
      "Epoch 401/500\n",
      "1/1 [==============================] - 0s 955us/step - loss: 1.9753e-04\n",
      "Epoch 402/500\n",
      "1/1 [==============================] - 0s 873us/step - loss: 1.9347e-04\n",
      "Epoch 403/500\n",
      "1/1 [==============================] - 0s 942us/step - loss: 1.8950e-04\n",
      "Epoch 404/500\n",
      "1/1 [==============================] - 0s 877us/step - loss: 1.8561e-04\n",
      "Epoch 405/500\n",
      "1/1 [==============================] - 0s 891us/step - loss: 1.8179e-04\n",
      "Epoch 406/500\n",
      "1/1 [==============================] - 0s 837us/step - loss: 1.7806e-04\n",
      "Epoch 407/500\n",
      "1/1 [==============================] - 0s 803us/step - loss: 1.7440e-04\n",
      "Epoch 408/500\n",
      "1/1 [==============================] - 0s 864us/step - loss: 1.7082e-04\n",
      "Epoch 409/500\n",
      "1/1 [==============================] - 0s 2ms/step - loss: 1.6731e-04\n",
      "Epoch 410/500\n",
      "1/1 [==============================] - 0s 756us/step - loss: 1.6387e-04\n",
      "Epoch 411/500\n",
      "1/1 [==============================] - 0s 694us/step - loss: 1.6051e-04\n",
      "Epoch 412/500\n",
      "1/1 [==============================] - 0s 749us/step - loss: 1.5721e-04\n",
      "Epoch 413/500\n",
      "1/1 [==============================] - 0s 839us/step - loss: 1.5398e-04\n",
      "Epoch 414/500\n",
      "1/1 [==============================] - 0s 19ms/step - loss: 1.5082e-04\n",
      "Epoch 415/500\n",
      "1/1 [==============================] - 0s 710us/step - loss: 1.4772e-04\n",
      "Epoch 416/500\n",
      "1/1 [==============================] - 0s 953us/step - loss: 1.4468e-04\n",
      "Epoch 417/500\n",
      "1/1 [==============================] - 0s 970us/step - loss: 1.4171e-04\n",
      "Epoch 418/500\n",
      "1/1 [==============================] - 0s 926us/step - loss: 1.3880e-04\n",
      "Epoch 419/500\n",
      "1/1 [==============================] - 0s 928us/step - loss: 1.3595e-04\n",
      "Epoch 420/500\n",
      "1/1 [==============================] - 0s 2ms/step - loss: 1.3316e-04\n",
      "Epoch 421/500\n",
      "1/1 [==============================] - 0s 751us/step - loss: 1.3042e-04\n",
      "Epoch 422/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 1.2774e-04\n",
      "Epoch 423/500\n",
      "1/1 [==============================] - 0s 829us/step - loss: 1.2512e-04\n",
      "Epoch 424/500\n",
      "1/1 [==============================] - 0s 800us/step - loss: 1.2255e-04\n",
      "Epoch 425/500\n",
      "1/1 [==============================] - 0s 827us/step - loss: 1.2003e-04\n",
      "Epoch 426/500\n",
      "1/1 [==============================] - 0s 894us/step - loss: 1.1757e-04\n",
      "Epoch 427/500\n",
      "1/1 [==============================] - 0s 744us/step - loss: 1.1515e-04\n",
      "Epoch 428/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 1.1279e-04\n",
      "Epoch 429/500\n",
      "1/1 [==============================] - 0s 976us/step - loss: 1.1047e-04\n",
      "Epoch 430/500\n",
      "1/1 [==============================] - 0s 761us/step - loss: 1.0820e-04\n",
      "Epoch 431/500\n",
      "1/1 [==============================] - 0s 912us/step - loss: 1.0598e-04\n",
      "Epoch 432/500\n",
      "1/1 [==============================] - 0s 915us/step - loss: 1.0380e-04\n",
      "Epoch 433/500\n",
      "1/1 [==============================] - 0s 894us/step - loss: 1.0167e-04\n",
      "Epoch 434/500\n",
      "1/1 [==============================] - 0s 803us/step - loss: 9.9582e-05\n",
      "Epoch 435/500\n",
      "1/1 [==============================] - 0s 785us/step - loss: 9.7536e-05\n",
      "Epoch 436/500\n",
      "1/1 [==============================] - 0s 788us/step - loss: 9.5533e-05\n",
      "Epoch 437/500\n",
      "1/1 [==============================] - 0s 832us/step - loss: 9.3570e-05\n",
      "Epoch 438/500\n",
      "1/1 [==============================] - 0s 808us/step - loss: 9.1648e-05\n",
      "Epoch 439/500\n",
      "1/1 [==============================] - 0s 732us/step - loss: 8.9766e-05\n",
      "Epoch 440/500\n",
      "1/1 [==============================] - 0s 741us/step - loss: 8.7923e-05\n",
      "Epoch 441/500\n",
      "1/1 [==============================] - 0s 993us/step - loss: 8.6116e-05\n",
      "Epoch 442/500\n",
      "1/1 [==============================] - 0s 818us/step - loss: 8.4347e-05\n",
      "Epoch 443/500\n",
      "1/1 [==============================] - 0s 910us/step - loss: 8.2616e-05\n",
      "Epoch 444/500\n",
      "1/1 [==============================] - 0s 908us/step - loss: 8.0918e-05\n",
      "Epoch 445/500\n",
      "1/1 [==============================] - 0s 735us/step - loss: 7.9256e-05\n",
      "Epoch 446/500\n",
      "1/1 [==============================] - 0s 999us/step - loss: 7.7629e-05\n",
      "Epoch 447/500\n",
      "1/1 [==============================] - 0s 787us/step - loss: 7.6034e-05\n",
      "Epoch 448/500\n",
      "1/1 [==============================] - 0s 869us/step - loss: 7.4472e-05\n",
      "Epoch 449/500\n",
      "1/1 [==============================] - 0s 919us/step - loss: 7.2942e-05\n",
      "Epoch 450/500\n",
      "1/1 [==============================] - 0s 908us/step - loss: 7.1444e-05\n",
      "Epoch 451/500\n",
      "1/1 [==============================] - 0s 781us/step - loss: 6.9977e-05\n",
      "Epoch 452/500\n",
      "1/1 [==============================] - 0s 2ms/step - loss: 6.8539e-05\n",
      "Epoch 453/500\n",
      "1/1 [==============================] - 0s 900us/step - loss: 6.7133e-05\n",
      "Epoch 454/500\n",
      "1/1 [==============================] - 0s 956us/step - loss: 6.5753e-05\n",
      "Epoch 455/500\n",
      "1/1 [==============================] - 0s 918us/step - loss: 6.4403e-05\n",
      "Epoch 456/500\n",
      "1/1 [==============================] - 0s 913us/step - loss: 6.3081e-05\n",
      "Epoch 457/500\n",
      "1/1 [==============================] - 0s 755us/step - loss: 6.1785e-05\n",
      "Epoch 458/500\n",
      "1/1 [==============================] - 0s 881us/step - loss: 6.0516e-05\n",
      "Epoch 459/500\n",
      "1/1 [==============================] - 0s 2ms/step - loss: 5.9272e-05\n",
      "Epoch 460/500\n",
      "1/1 [==============================] - 0s 966us/step - loss: 5.8055e-05\n",
      "Epoch 461/500\n",
      "1/1 [==============================] - 0s 988us/step - loss: 5.6862e-05\n",
      "Epoch 462/500\n",
      "1/1 [==============================] - 0s 886us/step - loss: 5.5694e-05\n",
      "Epoch 463/500\n",
      "1/1 [==============================] - 0s 911us/step - loss: 5.4551e-05\n",
      "Epoch 464/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 5.3430e-05\n",
      "Epoch 465/500\n",
      "1/1 [==============================] - 0s 3ms/step - loss: 5.2333e-05\n",
      "Epoch 466/500\n",
      "1/1 [==============================] - 0s 778us/step - loss: 5.1258e-05\n",
      "Epoch 467/500\n",
      "1/1 [==============================] - 0s 987us/step - loss: 5.0205e-05\n",
      "Epoch 468/500\n",
      "1/1 [==============================] - 0s 810us/step - loss: 4.9173e-05\n",
      "Epoch 469/500\n",
      "1/1 [==============================] - 0s 979us/step - loss: 4.8163e-05\n",
      "Epoch 470/500\n",
      "1/1 [==============================] - 0s 874us/step - loss: 4.7175e-05\n",
      "Epoch 471/500\n",
      "1/1 [==============================] - 0s 823us/step - loss: 4.6205e-05\n",
      "Epoch 472/500\n",
      "1/1 [==============================] - 0s 844us/step - loss: 4.5256e-05\n",
      "Epoch 473/500\n",
      "1/1 [==============================] - 0s 874us/step - loss: 4.4327e-05\n",
      "Epoch 474/500\n",
      "1/1 [==============================] - 0s 813us/step - loss: 4.3416e-05\n",
      "Epoch 475/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 4.2524e-05\n",
      "Epoch 476/500\n",
      "1/1 [==============================] - 0s 19ms/step - loss: 4.1650e-05\n",
      "Epoch 477/500\n",
      "1/1 [==============================] - 0s 851us/step - loss: 4.0795e-05\n",
      "Epoch 478/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 3.9957e-05\n",
      "Epoch 479/500\n",
      "1/1 [==============================] - 0s 888us/step - loss: 3.9137e-05\n",
      "Epoch 480/500\n",
      "1/1 [==============================] - 0s 911us/step - loss: 3.8332e-05\n",
      "Epoch 481/500\n",
      "1/1 [==============================] - 0s 877us/step - loss: 3.7545e-05\n",
      "Epoch 482/500\n",
      "1/1 [==============================] - 0s 846us/step - loss: 3.6774e-05\n",
      "Epoch 483/500\n",
      "1/1 [==============================] - 0s 982us/step - loss: 3.6018e-05\n",
      "Epoch 484/500\n",
      "1/1 [==============================] - 0s 964us/step - loss: 3.5279e-05\n",
      "Epoch 485/500\n",
      "1/1 [==============================] - 0s 960us/step - loss: 3.4554e-05\n",
      "Epoch 486/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 3.3844e-05\n",
      "Epoch 487/500\n",
      "1/1 [==============================] - 0s 939us/step - loss: 3.3149e-05\n",
      "Epoch 488/500\n",
      "1/1 [==============================] - 0s 903us/step - loss: 3.2468e-05\n",
      "Epoch 489/500\n",
      "1/1 [==============================] - 0s 871us/step - loss: 3.1801e-05\n",
      "Epoch 490/500\n",
      "1/1 [==============================] - 0s 985us/step - loss: 3.1148e-05\n",
      "Epoch 491/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 3.0508e-05\n",
      "Epoch 492/500\n",
      "1/1 [==============================] - 0s 2ms/step - loss: 2.9881e-05\n",
      "Epoch 493/500\n",
      "1/1 [==============================] - 0s 935us/step - loss: 2.9268e-05\n",
      "Epoch 494/500\n",
      "1/1 [==============================] - 0s 2ms/step - loss: 2.8667e-05\n",
      "Epoch 495/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 2.8079e-05\n",
      "Epoch 496/500\n",
      "1/1 [==============================] - 0s 941us/step - loss: 2.7502e-05\n",
      "Epoch 497/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 2.6937e-05\n",
      "Epoch 498/500\n",
      "1/1 [==============================] - 0s 994us/step - loss: 2.6384e-05\n",
      "Epoch 499/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 2.5841e-05\n",
      "Epoch 500/500\n",
      "1/1 [==============================] - 0s 1ms/step - loss: 2.5311e-05\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "<tensorflow.python.keras.callbacks.History at 0x7f7b4c2be400>"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "model.fit(xs, ys, epochs=500)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "kaFIr71H2OZ-"
   },
   "source": [
    "Ok, now you have a model that has been trained to learn the relationshop between X and Y. You can use the **model.predict** method to have it figure out the Y for a previously unknown X. So, for example, if X = 10, what do you think Y will be? Take a guess before you run this code:\n",
    "\n",
    "到这里为止模型已经训练好了，它学习了X和Y之间的关系。现在，你可以使用**model.predict**方法来让它计算未知X对应的Y。例如，如果X=10，你认为Y会是什么？在运行下面代码之前，请猜一猜："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "oxNzL4lS2Gui"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[18.985321]]\n"
     ]
    }
   ],
   "source": [
    "print(model.predict([10.0]))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "btF2CSFH2iEX"
   },
   "source": [
    "You might have thought 19, right? But it ended up being a little under. Why do you think that is? \n",
    "\n",
    "Remember that neural networks deal with probabilities, so given the data that we fed the NN with, it calculated that there is a very high probability that the relationship between X and Y is Y=2X-1, but with only 6 data points we can't know for sure. As a result, the result for 10 is very close to 19, but not necessarily 19. \n",
    "\n",
    "As you work with neural networks, you'll see this pattern recurring. You will almost always deal with probabilities, not certainties, and will do a little bit of coding to figure out what the result is based on the probabilities, particularly when it comes to classification.\n",
    "\n",
    "你可能会想到19岁，对吧？但最后输出比19低了一丁点儿。这是为什么呢？因为神经网络处理的是概率，所以根据我们向神经元网络提供的数据，它计算出X和y之间的关系是y=2x-1的概率非常高。但由于只有6个数据点，无法完全确定x和y的函数关系。因此，10对应的y值非常接近19，但不一定正好是19。当使用神经网络时，会看到这种模式反复出现。你几乎总是在处理概率，而非确定的数值。并经常需要通过进一步编写程序，来找出概率所对应的结果，特别当处理分类问题时。"
   ]
  }
 ],
 "metadata": {
  "colab": {
   "name": "Colab1-for-deeplearn.ipynb",
   "provenance": [],
   "toc_visible": true,
   "version": "0.3.2"
  },
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
